<template>
  <section class="todoapp">
    <!-- 除了驼峰, 还可以使用-转换链接 -->
    <TodoHeader :list="list"></TodoHeader>
    <TodoMain :list="list"></TodoMain>
    <TodoFooter :list="list"></TodoFooter>
  </section>
</template>

<script>
// 1.0 样式引入
import './styles/base.css'
import './styles/index.css'

import TodoHeader from './components/TodoHeader'
import TodoMain from './components/TodoMain'
import TodoFooter from './components/TodoFooter'

export default {
  components: {
    TodoHeader,
    TodoMain,
    TodoFooter
  },
  data () {
    return {
      list: JSON.parse(localStorage.getItem('todo')) || []
    }
  },
  watch: {
    list: {
      deep: true,
      immediate: true,
      handler () {
        localStorage.setItem('todo', JSON.stringify(this.list))
      }
    }
  }
}
</script>
